;;; tones.el --- Generate tones

;; Copyright 2007 Lukas Loehrer
;;
;; Author: loehrerl [at] gmx [dot] net
;; Version: $Id: tones.el,v 0.0 2007/01/27 19:13:43 luke Exp $
;; Keywords: 
;; X-URL: not distributed yet

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

;;; Commentary:

;;  This library requires the "tones" program that is part of the
;; siggen package by Jim Jackson. Siggen is available from:
;; http://www.comp.leeds.ac.uk/jj/linux/siggen.html

;; Put this file into your load-path and the following into your ~/.emacs:
;;   (require 'tones)

;;; Code:

(provide 'tones)
(eval-when-compile
  (require 'cl))

(defconst tones-command "aoss tones -i -"
  "Command for starting the tones program.")

(defvar tones-process nil
  "Process for the tones binary.")

(defun tones-initialize (&optional default-duration)
  "Start the tones process."
  (interactive)
  (unless default-duration
	(setq default-duration 200))
  (setq tones-process (start-process  "tones" "*tones-process*" "aoss" "tones" "-i" "-"))
  (process-send-string tones-process (format "absolute\n%d\n" default-duration)))

(defsubst tones-generate (freq duration volume)
  (when tones-process
	(process-send-string
tones-process (format "%d@%d:%d\n" freq volume duration))))

;; XXX: why does this give an invalid read syntax  error on execution?
(defun* tones-generate* (freq &key (dur 200) (vol -12) (rep 1) (pause 0))
  "Play tone(s)"
  (tones-generate freq dur vol))



;;{{{  emacs local variables

;;; local variables:
;;; folded-file: t
;;; byte-compile-dynamic: t
;;; end:

;;}}}

;;; tones.el ends here
